<template>
	<view class="ewm-page">
		<u-navbar title="二维码" title-color="#333" back-icon-color="#333">
			<view class="slot-wrap">
				<view class="">
					<text></text>
				</view>
				<view class="qh-dd-an">
					<!-- <text>切换订单</text> -->
					<view class="">
						<u-button @click="tabcl" type="primary" shape="circle">切换订单</u-button>
					</view>
					
				</view>
			</view>
		</u-navbar>
		<view v-if="queryCodeList!=''" class="ewm-main">
			<view class="code-tximg" v-if="txmis=='1'">
				<image :src="txbinary" mode="" />
			</view>
			<view v-if="txmis=='0'" class="code-img">
				<image :src="binary" mode="" />
			</view>
			<view class="ERcode-orderinfo">
				<view class="ERcode-orderinfo-view"><text style="color: red;">{{queryCodeList.ORMTB440CA01||''}}</text><text
						style="color: #32CD32;">{{queryCodeList.ORMTB440CF01=='0'?'待接单':queryCodeList.ORMTB440CF01=='1'?'待提货':queryCodeList.ORMTB440CF01=='2'?'提货中':''||''}}</text>
				</view>
				<view><text>订单编号：</text>{{queryCodeList.ORMTB440CA00||''}}</view>
				<view><text>下单时间：</text>{{queryCodeList.ORMTB440CA19||''}}</view>
				<view style="color:#99CC32;"><text>企业：</text>{{queryCodeList.ORMTB440CA24||''}}</view>
				<view style="color:#32CD99;"><text>物料：</text>{{queryCodeList.ORMTB440CA07||''}}</view>
				<view>
					<text>下单方式：</text>{{queryCodeList.ORMTB440CA09=='JZ'?'净重':queryCodeList.ORMTB440CA09=='MZ'?'毛重':''||''}}
				</view>
				<view style="color:#D98719;"><text>吨数：</text>{{queryCodeList.ORMTB440CA10||''}}</view>
			</view>
		</view>
		<view class="zanWSJ" v-if="queryCodeList==''">
			<image :src="getStaticFilePath('/QXY/noData.png')" alt="">
		</view>
		
	</view>
</template>

<script>
	import md5 from '../../util/MD5.js'
	export default {
		data() {
			return {
				screeningshow: false,
				codeShow: false,
				type: '', // 1 派单时间 2 结算时间
				//订单列表
				orderList: [],
				brightness: null,
				current: 1, // tabs组件的current值，表示当前活动的tab选项
				swiperCurrent: 0, // swiper组件的current值，表示当前那个swiper-item是活动的
				list: [{
						name: '全部'
					},
					{
						name: '待接单'
					},
					{
						name: '待提货'
					},
					{
						name: '提货中',
					},
					{
						name: '已完成',
					},
					{
						name: '已回执',
					},
					{
						name: '确认回执',
					},
					{
						name: '已取消',
					},
					{
						name: '待审核',
					}
				],
				status: 'loading',
				iconType: 'flower',
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '实在没有了'
				},
				countpage: 1,
				page: 1,
				userinfo: JSON.parse(uni.getStorageSync('userinfo')),
				dataStatisCount: [],
				totalWeight: 0,
				totalAmount: 0,
				totalCarCount: 0,
				params: {
					year: true,
					month: true,
					day: true,
					hour: true,
					minute: true,
					second: true
				},
				year: '',
				systemInfo: uni.getSystemInfoSync(),
				navHeight: '',
				optionHeight: 35,
				enterpriseName: '全部',
				erpshow: false,
				erpId: '',
				erpcColumns: [],
				stattimeshow: false,
				endtimeshow: false,
				dateStartStr: '',
				dateEndStr: '',
				materName: '全部',
				matershow: false,
				materColumns: [],
				materId: '',
				carshow: false,
				carNumberName: '全部车牌号',
				carkeyword: '',
				carKeyWordshow: false,
				carList: [],
				binary: '',
				txbinary:'',
				ordercoutObj: '',
				AuthorizationOBJ: '',
				queryCodeList: '',
				testdata: {
					binary: '',
					queryCodeList: ''
				},
				txmis:''
			};
		},
		onShow(e) {
			let that = this
			uni.$on('updateData', function(data) {
				console.log(data)
				// that.testdata = data
				// console.log(that.testdata)
				// const params = 'binary:' + data.binary + ', queryCodeList:' + data.queryCodeList;
				// console.log('监听到事件来自 updateData ，携带参数为：' + params);
				that.queryCodeList = ''
				that.txbinary = ''
				that.binary = ''
				that.txmis = data.txm
				if(data.txm =='1'){
					that.txbinary = 'data:image/png;base64,' + data.ORMTB440CA22
				}
				else{
					that.binary = 'data:image/png;base64,' + data.ORMTB440CA22
				}
				that.queryCodeList = data
				console.log(that.queryCodeList)
				// that.binary = data.binary
				// that.queryCodeList = data.queryCodeList
			})
		},
		onLoad() {
			// console.log(this.testdata)
			// if(this.testdata == ''){
			// 	this.querycode()
			// }
			this.querycode()
			
			// 屏幕常亮
			// uni.setScreenBrightness({
			// 	value: 1,
			// 	success: function () {
			// 		console.log('success');
			// 	},
			// 	fail:function(){

			// 	}
			// });
		},

		mounted() {
			uni.getScreenBrightness({ // 获取屏幕亮度
				success: res => {
					if (res.value !== 1) {
						this.brightness = res.value // 屏幕亮度值，范围 0~1，0 最暗，1 最亮
						uni.setScreenBrightness({ // 设置屏幕亮度
							value: 1 // 屏幕亮度值，范围 0~1，0 最暗，1 最亮
						})
					}
				}
			})
		},
		beforeDestroy() {
			if (this.brightness != null) {
				uni.setScreenBrightness({ // 设置屏幕亮度到进入时的亮度
					value: this.brightness
				})
			}
		},

		methods: {
			querycode() {
				const tim = new Date().valueOf() // 方法一
				var key = '25ee70b9f3354703647a437e491c0ac7' + tim + 'hf&*/*6'
				var p1 = md5.hex_md5(key)
				uni.showLoading({
					title: '加载中...',
					mask: true
				});
				this.binary = ''
				this.txbinary = ''
				uni.request({
					url: this.baseUrl + '/orm/ormtb440/selectQRCode',
					method: 'POST',
					dataType: 'json',
					data: {
						ORMTB410ID: this.userinfo.ORMTB410ID, //二级客户ID
						ORMTB410CA02: this.userinfo.ORMTB410CA02,
						key:p1,
						time:tim
					},
					success: (res) => {
						console.log(res);
						uni.hideLoading();
						if (res.data.code == 200) {
							var data = res.data.data
							this.txmis = data.txm
							console.log(this.txmis)
							if(this.txmis =='1'){
								this.txbinary = 'data:image/png;base64,' + data.ORMTB440CA22
							}
							else{
								this.binary = 'data:image/png;base64,' + data.ORMTB440CA22
							}
							this.queryCodeList = data
						} else {
							uni.showToast({
								title: res.data.message,
								duration: 5000,
								icon: 'none',
							});
						}
					},
					fail: (res) => {
						console.log(res)
						uni.hideLoading();
						uni.showToast({
							title: res.data.message,
							duration: 5000,
							icon: 'none',
						});
					}
				});
			},
			tabcl() {
				uni.navigateTo({
					url: '/pages/ordeVehicle/index'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.ewm-page{
		display: flex;
		flex-direction: column;
		height: calc(100vh - var(--window-top));
		width: 100%;
		background-color: #E3E3E3;
	}
	.ewm-main{
		background-color:#ffffff;
		height: calc(100vh - var(--window-top));
	}
	.slot-wrap {
		display: flex;
		align-items: center;
		justify-content: space-between;
		/* 如果您想让slot内容占满整个导航栏的宽度 */
		flex: 1;
		/* 如果您想让slot内容与导航栏左右有空隙 */
		padding: 0 30rpx;
	}

	.ERcode-orderinfo {
		font-size: 36rpx;
		color: #333;
		margin-bottom: 65rpx;
		padding: 0 28rpx;
	}

	.ERcode-orderinfo>view {
		// height: 44rpx;
		line-height: 44rpx;
		overflow: hidden;
	}

	.ERcode-orderinfo-view {
		border-bottom: 2rpx solid #e3e3e3;
		padding-bottom: 20rpx;
	}

	.ERcode-orderinfo-view>text:first-child {
		font-size: 44rpx;
		font-weight: 600;
		width: 255rpx !important;
	}

	.ERcode-orderinfo>view+view {
		margin-top: 15rpx;
	}

	.ERcode-orderinfo text {
		display: inline-block;
		font-size: 36rpx;
		width: 190rpx;
		text-align: right;
		margin-right: 21rpx;
		color: #666;
	}

	.code-img {
		width: 500rpx;
		height: 500rpx;
		margin: 50rpx auto 0;
	}

	.code-img image {
		width: 500rpx;
		height: 500rpx;
	}
	
	.code-tximg{
		width: 500rpx;
		height: 150rpx;
		margin: 50rpx auto 0;
		margin-bottom: 20rpx;
	}
	
	.code-tximg image {
		width: 500rpx;
		height: 150rpx;
	}
	
	.zanWSJ {
		padding-top: 200rpx;
	}
	
	.zanWSJ>image {
		display: block;
		margin: 0 auto;
		height: 360rpx;
		width: 43%;
	}
</style>
